package com.indexingsystem.system.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.indexingsystem.boss.Vo.IdxProductInnerTextDetailListVo;
import com.indexingsystem.boss.Vo.IdxProductInnerTextSelectDetailReqVo;
import com.indexingsystem.boss.Vo.IdxProductSelectReqVo;
import com.indexingsystem.boss.Vo.IdxProductsQueryVo;
import com.indexingsystem.boss.admin.mapper.IdxProductsMapper;
import com.indexingsystem.boss.common.PagedResult;
import com.indexingsystem.boss.entity.IdxProducts;
import com.indexingsystem.boss.utils.BeanUtils;
import com.indexingsystem.system.service.IdxProductsService;

@Service
public class IdxProductsServiceImpl implements IdxProductsService {

	@Resource
	private IdxProductsMapper idxProductsMapper;
	
	@Override
	public int deleteByPrimaryKey(String productId) {
		return idxProductsMapper.deleteByPrimaryKey( productId );
	}

	@Override
	public int insert(IdxProducts record) {
		return idxProductsMapper.insert( record );
	}

	@Override
	public int insertSelective(IdxProducts record) {
		return idxProductsMapper.insertSelective( record );
	}

	@Override
	public IdxProducts selectByPrimaryKey(String productId) {
		return idxProductsMapper.selectByPrimaryKey( productId );
	}

	@Override
	public int updateByPrimaryKeySelective(IdxProducts record) {
		return idxProductsMapper.updateByPrimaryKeySelective( record );
	}

	@Override
	public int updateByPrimaryKeyWithBLOBs(IdxProducts record) {
		return idxProductsMapper.updateByPrimaryKeyWithBLOBs( record );
	}

	@Override
	public int updateByPrimaryKey(IdxProducts record) {
		return idxProductsMapper.updateByPrimaryKey( record );
	}

	@Override
	public Integer deleteByIdBatch(List<String> list) {
		return idxProductsMapper.deleteByIdBatch( list );
	}

	@Override
	public PagedResult<IdxProductsQueryVo> getProductList(IdxProductSelectReqVo idxProductSelectReqVo) {
		Integer pageNo = idxProductSelectReqVo.getPageNo() == null ? 1 : idxProductSelectReqVo.getPageNo();
		Integer pageSize = idxProductSelectReqVo.getPageSize() == null ? 10 : idxProductSelectReqVo.getPageSize();
		//startPage是告诉拦截器说我要开始分页了。分页参数是这两个。
		PageHelper.startPage(pageNo,pageSize);  
		return BeanUtils.toPagedResult(idxProductsMapper.getProductList(idxProductSelectReqVo));
	}

	@Override
	public Integer getProductListCount(IdxProductSelectReqVo idxProductSelectReqVo) {
		return idxProductsMapper.getProductListCount( idxProductSelectReqVo );
	}

	@Override
	public IdxProductInnerTextDetailListVo selectIdxProduct(
			String productId) {
		// TODO Auto-generated method stub
		return idxProductsMapper.selectIdxProduct(productId);
	}

	@Override
	public Integer selectIdxProductCount(String productId) {
		// TODO Auto-generated method stub
		return idxProductsMapper.selectIdxProductCount(productId);
	}

}
